package com.scheduler.backend.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.*;


import org.json.JSONObject;

import java.util.HashMap;
import java.util.Map;

/**
 * @author Lucas Von
 * @date 2021/1/9
 */
@RestController
@CrossOrigin
@Tag(name = "登录相关接口")
public class LoginController {
    @RequestMapping(value = "/login", method = RequestMethod.POST)
    @Operation(summary = "登录", description = "登录", method = "POST")
//    @ResponseBody
    public String login(){
        JSONObject res = new JSONObject();
        res.put("code", 200);
        JSONObject data = new JSONObject();
        data.put("accessToken", "admin-accessToken");
        res.put("data", data);
        res.put("msg", "success");
        return res.toString();
    }

    @RequestMapping(value = "/userInfo", method = RequestMethod.POST)
    @Operation(summary = "用户信息", description = "用户信息", method = "POST")
    @ResponseBody
    public Map<String, Object> userInfo(){
        Map<String,Object> res = new HashMap<>();
        res.put("code", 200);
        Map<String,Object> data = new HashMap<>();
        data.put("avatar", "https://i.gtimg.cn/club/item/face/img/8/15918_100.gif");
        data.put("permissions", new String[]{"admin"});
        data.put("username", "admin");
        res.put("data", data);
        res.put("msg", "success");
        return res;
    }
}
